var POLE_STARTING_Y = 0;
var POLE_HEIGHT = 600;
var TULIP_HEIGHT = 100;

var TULIP_POINTS = 70;
var ATTEMPT_BONUS_POINTS = 100;

var numberOfTulips;
var tulipNumber;

function Game()
{
	this.score = 0;
	this.level = 1;
	this.attempts = 5;
	this.tulipHeights = new Array();
	
}

Game.prototype.resetGame = function()
{
	this.score = 0;
	this.level = 1;
	this.attempts = 5;
	this.tulipHeights = new Array();
}

Game.prototype.setGameLevel = function()
{
	numberOfTulips = this.getNumberOfTulips();
	this.tulipHeights = new Array( numberOfTulips );
	
	this.setAttempts( this.getNumberOfAttempts() );
	
	var numberOfIntervals = Math.floor( ( POLE_HEIGHT - TULIP_HEIGHT * 2 ) / TULIP_HEIGHT );
	
	for( i = 0; i < numberOfTulips; i = i + 1 )
		{
			var height = Math.floor( Math.random() * numberOfIntervals ) * TULIP_HEIGHT + POLE_STARTING_Y + TULIP_HEIGHT;
			this.tulipHeights[ i ] = height;
		}
}

Game.prototype.getNumberOfTulips = function ()
{
	
	if( this.level == 1 )
		{
			return 1;
		}
	
	else if( this.level == 2 )
		{
			return 3;
		}
	
	else if( this.level == 3)
		{
			return 5;
		}
	
	else if( this.level == 4 )
		{
			return 4;
		}
	
	else if( this.level == 5 )
	    {
	     	return 2;
	    }
    else
     	{
	     	return 0;
	    }
}

Game.prototype.getNumberOfAttempts = function()
{
	
	if( this.level == 1 )
		{
			return 4;
		}
	
	if( this.level == 2 )
		{
			return 5;
		}
	
	if( this.level == 3 )
		{
			return 6;
		}
	
	if( this.level == 4 )
		{
			return 5;
		}
	
	if( this.level == 5 )
		{
			return 3;
		}
}
Game.prototype.checkGameStatus = function()
{
	if( this.attempts == 0 || tulipNumber >= 1 )
		{
			return drawLoserCanvas();
		}
	else 
		{
		  if ( this.level == 6 && tulipNumber == 0 )
		       {
			     return drawWinnerCanvas();
		       }
			
		}
}

Game.prototype.getScore = function()
{
	return this.score;
}

Game.prototype.setScore = function( score )
{
	this.score = score;
}

Game.prototype.getLevel = function()
{
	return this.level;
}

Game.prototype.setLevel = function( level )
{
	this.level = level;
}

Game.prototype.getAttempts = function()
{
	return this.attempts;
}

Game.prototype.setAttempts = function( attempts )
{
	this.attempts = attempts;
}

Game.prototype.getTulipHeights = function()
{
	return this.tulipHeights;
}